﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xrm.Sdk;
using System.Globalization;
using System.Threading;

namespace CrmWorkflowDependencies.Crm.Extension
{
    public static class AttributeCollectionExtensions
    {
        public static int GetPicklistValue(this AttributeCollection properties, string name)
        {
            return GetPicklistValue(properties, name, -1);
        }

        public static int GetPicklistValue(this AttributeCollection properties, string name, int defaultValue)
        {
            if (properties.Contains(name))
            {
                object property = properties[name];
                OptionSetValue p = property as OptionSetValue;
                if (p != null)
                {
                    return p.Value;
                }
            }
            return defaultValue;
        }
    }
}
